<template>
	<view class="classContent">
		<view style="height: 20rpx;"></view>
		<view style="width: 690rpx;display: flex;flex-wrap: wrap;">
			<view v-for="(item,index) in classList" :key="index" style="width: 330rpx;height: 320rpx;">
				<image 
				@click="handeleNav(item)"
				mode="widthFix" 
				:src="lang==='zh'?IMGURL+item.image:IMGURL+item.image_ru" 
				:class="(index % 2 === 0)?'images_urla':'images_urlb'"
				></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		IMAGE_URL,
		HTTP_IMG_UTL
	} from '@/config/app';
	export default{
		data(){
			return{
				type:0,
				classList:[],//分类
				IMGURL:'https://app.gluz.com.cn/',//图片地址
				lang:'zh',//语言
			}
		},
		onLoad(options) {
			// this.IMGURL = IMAGE_URL
			this.type = options.type
			// 获取分类
			this.getActionSheetLists()
		},
		onShow() {
			// 获取语言
			this.getLang()			
		},
		methods:{
			// 页面跳转
			handeleNav(item){
				uni.navigateTo({
					url:'/pages/index/goodsPromotion/goodsPromotion1??id='+item.id+'&name='+item.name+'&name_ru='+item.name_ru
				})
				
			},
			// 获取语言
			getLang() {
				// 获取缓存lang当前语言值
				uni.getStorage({
					key: 'lang',
					success: res => {
						if (res.data == 'zh') { //zh为中国，赋值0
							this.lang = 'zh'
						} else { //其他为俄罗斯，赋值1
							this.lang = 'ru'
						}
					}
				});
			},
			// 获取分类
			getActionSheetLists() {
				let data = {
					type: "release_goods",
				}
				this.$u.api.basic.getActionSheetList(data).then(res => {
					console.log('res:',res);
					this.classList = res
				})
			},
		},
		onReady() {
			uni.setNavigationBarTitle({
				title: this.$t("采购订单")
			})
		},
	}
</script>

<style scoped>
	.images_urla{
		width: 330rpx;
		height: 320rpx;
		margin-bottom: 20rpx;
	}
	.images_urlb{
		width: 330rpx;
		height: 320rpx;
		margin-left: 23rpx;
		margin-bottom: 20rpx;
	}
	.classContent{
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
</style>
<style>
	page {
		background-color: #F6F6F6;
	}
</style>